package ControlLayer;
import java.util.ArrayList;
import ControlLayer.AddressCtr;
import ControlLayer.DVDCtr;
import ModelLayer.LoanContainer;
import ModelLayer.Loan;
import ModelLayer.AddressBook;
import ModelLayer.Person;
import ModelLayer.DVDContainer;
import ModelLayer.DVD;
import ModelLayer.Copy;

/**
 * Write a description of class LoanCtr here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class LoanCtr
{
    private LoanContainer loanContainer;
    private AddressCtr addressCtr;
    private DVDCtr dvdCtr;

    public LoanCtr()
    {
        loanContainer = LoanContainer.getInstance();
    } 
    
    public void createLoan(Person loanPerson, String dvdTitle, 
                           int borrowDay, int borrowMonth, int returnDay, int returnMonth)
    {   
        DVD dvd = DVDContainer.getInstance().getDVD(dvdTitle);
        Copy loanCopy = DVDContainer.getInstance().findCopy(dvdTitle);
        
        if (loanPerson != null && dvdTitle != null && loanCopy != null && borrowDay > 0 && 
            borrowMonth > 0 && returnDay > 0 && returnMonth > 0)
        {
            loanContainer.createLoan(loanPerson, dvd, loanCopy, borrowDay, borrowMonth, returnDay, returnMonth);
        }
    
    }  
    
    public Loan findLoan(long searchLoanID)
    {
        return findLoan(searchLoanID);
    }
   
    public void deleteLoan(long searchLoanID)
    {   
        loanContainer.deleteLoan(searchLoanID);
    }
    
    public ArrayList listAllLoans()
    {   
        return loanContainer.listAllLoans();
    }
}
